<html>
<head><meta charset="utf-8"><title>Rustc elf32-x86_64 · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustc.20elf32-x86_64.html">Rustc elf32-x86_64</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213527720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustc%20elf32-x86_64/near/213527720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Soveu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustc.20elf32-x86_64.html#213527720">(Oct 16 2020 at 07:42)</a>:</h4>
<p>Would it be possible for rustc to emit 32bit ELFs, but with x86_64 code?<br>
It would allow linking to elf32-i386, which QEMU wants for kernels passed with <code>-kernel</code> argument.</p>



<a name="213535080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustc%20elf32-x86_64/near/213535080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Soveu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustc.20elf32-x86_64.html#213535080">(Oct 16 2020 at 09:02)</a>:</h4>
<p>or tell the linker to not worry about linking elf64 into elf32?</p>



<a name="213591229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustc%20elf32-x86_64/near/213591229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustc.20elf32-x86_64.html#213591229">(Oct 16 2020 at 17:40)</a>:</h4>
<p>Are you using the bzImage support, or multiboot?</p>



<a name="213591422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustc%20elf32-x86_64/near/213591422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustc.20elf32-x86_64.html#213591422">(Oct 16 2020 at 17:41)</a>:</h4>
<p>In any case, it's common for an x86 kernel to contain 64-bit, 32-bit, and even 16-bit code in the same binary. I would just tell the linker to accept that.</p>



<a name="215009227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustc%20elf32-x86_64/near/215009227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Soveu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustc.20elf32-x86_64.html#215009227">(Oct 29 2020 at 18:31)</a>:</h4>
<p>Oh, i haven't been on zulip for a while <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> </p>
<p>The problem isn't with code inside ELFs, the problem is that compiling for 64bit targets produces ELFs with ELFCLASS64 - offsets are 64bit, so these don't match with 32bit class ELFs</p>
<p>I'm using multiboot and currently writing a multiboot-to-longmode bootloader, since I'll need an elf loader anyways</p>
<p>I've read somewhere, that people use <code>objcopy</code> for "transforming" elf32 to elf64, but i dont want to have problems with it later, especially with higher-half kernel</p>



<a name="215009633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustc%20elf32-x86_64/near/215009633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Soveu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustc.20elf32-x86_64.html#215009633">(Oct 29 2020 at 18:34)</a>:</h4>
<p><a href="https://github.com/Soveu/osdev">For anyone interested in code</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>